<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>导入文件下载</title>
    <link href="../css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="../css/charisma-app.css" rel="stylesheet">
    <link href='../css/chosen.css' rel='stylesheet'>
    <link href='../css/uniform.default.css' rel='stylesheet'>
    <link href='../css/uploadify.css' rel='stylesheet'>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>
    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script src="../js/common/public.js"></script>
    <script src="../js/base64.js"></script>
    <script src="../js/bootstrap-modal.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            var html = $.ajax({
                type: "GET",
                url: "http://localhost:1068/admin/fileList?token=" + urlMsg.token + "&type=" + 2,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                for (index in result.data) {
                    addImportDataTable(result.data[index].id,
                        result.data[index].title,
                        result.data[index].path,
                        result.data[index].userName,
                        result.data[index].date);

                }
            }
            $('#downloadStudent').attr('href','http://localhost:1068/admin/downloadAll?token='+urlMsg.token+"&downloadType=studentInfo&downFileName=学生操行");
            $('#downloadClass').attr('href','http://localhost:1068/admin/downloadAll?token='+urlMsg.token+"&downloadType=classInfo&downFileName=班级量化");

        });

        function addImportDataTable(id, title, path, userName, date) {

            $("#studentInfo tbody").append(" <tr class='odd'>\n" +
                "<td class='center '>\n" +
                "<button type='button' id='download" + id + "' class='btn btn-success' onclick='downloadFile(id=" + id + ",this);'>\n" +
                "" + title + "" +
                "</button>\n" +
                "</td>\n" +
                "<td class='center '>\n" +
                "" + date + "" +
                "</td>\n" +
                "<td class='center '>\n" +
                "" + userName + "" +
                "</td>\n" +
                "</tr>");
        }

        function downloadFile(id, a) {
            var urlMsg = parseUrl(window.location.search);
            var html = $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/download",
                data: {token: urlMsg.token, id: id},
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                var a = document.createElement('a');
                a.download = 'liu.xlsx';//下载的文件名
                a.href = result.data;
                $("body").append(a);    // 修复firefox中无法触发click
                a.click();
                $(a).remove();
            }

        }
      /*  function downloadStudentAll() {
            var urlMsg = parseUrl(window.location.search);
            var html = $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/downloadAll",
                data: {token: urlMsg.token, downloadType: "studentInfo",downFileName:"学生操行信息导出"},
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {

            }

        }
        function downloadClassAll() {
            var urlMsg = parseUrl(window.location.search);
            var html = $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/downloadAll",
                data: {token: urlMsg.token, downloadType: "classInfo",downFileName:"班级量化信息导出"},
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {

            }

        }*/

    </script>

</head>

<body>
<div class="container-fluid"
     style="padding-left:0px;padding-right:2px;">
    <div class="row-fluid">
        <div id="content" class="span10" style="width:100%;">
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header well">
                        <h2>
                            <i class="icon-edit"></i>导入数据信息 <font color="red">点击文件名即可下载（上传文件保存7天，如需修改，请联系管理员）</font>
                           <a href="" id="downloadStudent">点击下载所有已导出学生操行/</a>
                            <a href="" id="downloadClass">点击下载所有已导出班级量化</a>
                        </h2>
                    </div>


                    <!--  <span style="font-size:18px"><a href="">点此下载所有导入有问题的数据</a></span>-->
                    <table
                            class="table table-striped table-bordered bootstrap-datatable datatable dataTable"
                            id="studentInfo">
                        <thead>
                        <tr>
                            <th class="sorting_asc" rowspan="1" colspan="1" style="width: 100px;">名称</th>
                            <th class="sorting" rowspan="1" colspan="1" style="width: 50px;">上传时间</th>
                            <th class="sorting" rowspan="1" colspan="1" style="width: 50px;">操作员</th>
                        </tr>
                        </thead>

                        <tbody>

                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>